package String;

public class _520_DetectCapital {
    public boolean detectCapitalUse(String word) {
        if(word==null || word.length()==0) return false;
        if(word.length()==1) return true;
        int length = word.length();
        boolean capital = false;
        if (Character.isUpperCase(word.charAt(0))) {
            if (Character.isUpperCase(word.charAt(1))) {
                capital = true;
            }
        }
        for (int i = 1; i < length; i++) {
            if (capital) {
                if (!Character.isUpperCase(word.charAt(i))) {
                    return false;
                }
            } else {
                if (!Character.isLowerCase(word.charAt(i))) {
                    return false;
                }
            }
        }
        return true;
    }
}
